package com.blank;

import com.blank.pojo.bo.User;
import com.blank.service.CheckLoginService;
import com.blank.service.Impl.CheckLoginServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @author BLANK
 * @date 2020/11/16
 */
@WebServlet( "/CheckSameUserServlet")
public class CheckSameUserServlet extends HttpServlet {
    private CheckLoginService checkLoginService = new CheckLoginServiceImpl();

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String username=request.getParameter("username");
        try {
            User user = checkLoginService.checkSameUser(username);
            if (user!=null){
                response.getWriter().write("用户名已存在");
            }else{
                response.getWriter().write("success");
            }
        } catch (SQLException throwable) {
            throwable.printStackTrace();
        }
    }
}
